'
' Copyright (c) 2004-2005
' by Peter Donker ( info@bring2mind.net )
'
' Permission is hereby granted to use and/or modify this software for a single server. It is 
' NOT permitted to publish, distribute, sublicense, and/or sell copies of this software in its
' original or modified form. You are not allowed to remove this copyright notice.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
' BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
' NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
' DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF THE SOFTWARE.
'
Namespace Bring2mind.DNN.Modules.Guestbook
 Public Class ModuleSettings

#Region " Private Members "
  Private _Roles As String = ""
  Private _CanAdd As Boolean = False
  Private _PageSize As Integer = 10
  Private _NotificationEmail As String = ""
  Private _DateFormat As String = "MMM-dd"
  Private _ApprovalRole As Integer = -1
  Private _CanApprove As Boolean = False
  Private _AutoApprove As Boolean = False
  Private _AllowPictures As Boolean = True
  Private _MaxPictureSize As Integer = 500
  Private _ThumbnailSize As Integer = 100
  Private _AllowHtml As Boolean = True
#End Region

#Region " Constructors "
  Public Sub New(ByVal ModuleId As Integer)

   Dim mc As New DotNetNuke.Entities.Modules.ModuleController
   Dim Settings As Hashtable = mc.GetModuleSettings(ModuleId)


   If Not Settings.Item("Roles") Is Nothing Then
    Roles = CType(Settings.Item("Roles"), String)
   End If

   If Not Settings.Item("PageSize") Is Nothing Then
    PageSize = CType(Settings.Item("PageSize"), Integer)
   End If

   If Not Settings.Item("NotificationEmail") Is Nothing Then
    NotificationEmail = CType(Settings.Item("NotificationEmail"), String)
   End If

   If Not Settings.Item("DateFormat") Is Nothing Then
    DateFormat = CType(Settings.Item("DateFormat"), String)
   End If

   If Not Settings.Item("ApprovalRole") Is Nothing Then
    ApprovalRole = CType(Settings.Item("ApprovalRole"), Integer)
   End If

   If Not Settings.Item("AllowPictures") Is Nothing Then
    AllowPictures = CType(Settings.Item("AllowPictures"), Boolean)
   End If

   If Not Settings.Item("MaxPictureSize") Is Nothing Then
    MaxPictureSize = CType(Settings.Item("MaxPictureSize"), Integer)
   End If

   If Not Settings.Item("ThumbnailSize") Is Nothing Then
    ThumbnailSize = CType(Settings.Item("ThumbnailSize"), Integer)
   End If

   If Not Settings.Item("AllowHtml") Is Nothing Then
    AllowHtml = CType(Settings.Item("AllowHtml"), Boolean)
   End If

   _AutoApprove = (ApprovalRole = -1)

  End Sub
#End Region

#Region " Public Members "
  Public Sub SaveSettings(ByVal ModuleId As Integer)

   Dim objModules As New DotNetNuke.Entities.Modules.ModuleController
   objModules.UpdateModuleSetting(ModuleId, "Roles", Me.Roles.ToString)
   objModules.UpdateModuleSetting(ModuleId, "PageSize", Me.PageSize.ToString)
   objModules.UpdateModuleSetting(ModuleId, "NotificationEmail", Me.NotificationEmail.ToString)
   objModules.UpdateModuleSetting(ModuleId, "DateFormat", Me.DateFormat.ToString)
   objModules.UpdateModuleSetting(ModuleId, "ApprovalRole", Me.ApprovalRole.ToString)
   objModules.UpdateModuleSetting(ModuleId, "AllowPictures", Me.AllowPictures.ToString)
   objModules.UpdateModuleSetting(ModuleId, "MaxPictureSize", Me.MaxPictureSize.ToString)
   objModules.UpdateModuleSetting(ModuleId, "ThumbnailSize", Me.ThumbnailSize.ToString)
   objModules.UpdateModuleSetting(ModuleId, "AllowHtml", Me.AllowHtml.ToString)

  End Sub
#End Region

#Region " Properties "

  Public ReadOnly Property AutoApprove() As Boolean
   Get
    Return _AutoApprove
   End Get
  End Property

  Public Property Roles() As String
   Get
    Return _Roles
   End Get
   Set(ByVal Value As String)
    _Roles = Value
   End Set
  End Property

  Public Property CanAdd() As Boolean
   Get
    Return _CanAdd
   End Get
   Set(ByVal Value As Boolean)
    _CanAdd = Value
   End Set
  End Property

  Public Property PageSize() As Integer
   Get
    Return _PageSize
   End Get
   Set(ByVal Value As Integer)
    _PageSize = Value
   End Set
  End Property

  Public Property NotificationEmail() As String
   Get
    Return _NotificationEmail
   End Get
   Set(ByVal Value As String)
    _NotificationEmail = Value
   End Set
  End Property

  Public Property DateFormat() As String
   Get
    Return _DateFormat
   End Get
   Set(ByVal Value As String)
    _DateFormat = Value
   End Set
  End Property

  Public Property ApprovalRole() As Integer
   Get
    Return _ApprovalRole
   End Get
   Set(ByVal Value As Integer)
    _ApprovalRole = Value
   End Set
  End Property

  Public Property CanApprove() As Boolean
   Get
    Return _CanApprove
   End Get
   Set(ByVal Value As Boolean)
    _CanApprove = Value
   End Set
  End Property

  Public Property AllowPictures() As Boolean
   Get
    Return _AllowPictures
   End Get
   Set(ByVal Value As Boolean)
    _AllowPictures = Value
   End Set
  End Property

  Public Property MaxPictureSize() As Integer
   Get
    Return _MaxPictureSize
   End Get
   Set(ByVal Value As Integer)
    _MaxPictureSize = Value
   End Set
  End Property

  Public Property ThumbnailSize() As Integer
   Get
    Return _ThumbnailSize
   End Get
   Set(ByVal Value As Integer)
    _ThumbnailSize = Value
   End Set
  End Property

  Friend Property AllowHtml() As Boolean
   Get
    Return _AllowHtml
   End Get
   Set(ByVal Value As Boolean)
    _AllowHtml = Value
   End Set
  End Property
#End Region

 End Class
End Namespace


